﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Smartmanufact
{
    public partial class CargoinfoEdit : Form
    {
        public string originid = "";
        public string originname = "";
        public string originnote = "";


        public CargoinfoEdit()
        {
            InitializeComponent();
        }

        private void CargoinfoEdit_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        public void Fill_Info()
        {
            textBox_id.Text = originid;
            textBox_name.Text = originname;
            richTextBox1.Text = originnote;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string updateid = textBox_id.Text.Trim();
                string updatename = textBox_name.Text.Trim();
                string updatenote = richTextBox1.Text.Trim();

                if (updateid == "") { MessageBox.Show("货物种类ID不能为空！"); return; }
                if (updatename == "") { MessageBox.Show("货物种类名称不能为空！"); return; }

                // 更新操作
                MainView.mysql.excute_sql("update cargoinfotable set cargoinfoID='" + updateid + "',cargoinfoname='" + updatename + "',note='" + updatenote + "' where cargoinfoID='"+originid+"'");
                this.Dispose();
            }
            catch { MessageBox.Show("修改过程中发生错误！"); }
        }
    }
}
